//声明式
function toggle(...actions) {
    return function (...args) {
        let action = actions.shift();
        actions.push(action);
        return action.apply(this, args);
    }
}

switcher.onclick = toggle(
    //应为默认是‘on’，所以‘on’要放到最下边
    // evt => evt.target.className = 'warn',
    evt => evt.target.className = 'off',
    evt => evt.target.className = 'on',
)